<?php
/**
 * Created by PhpStorm.
 * User: WenQing
 * Date: 2017/7/25
 * Time: 10:42
 */

$gurl = "http://www.basic.com/";
echo "以下是GET方式的响应内容：<br>";
sock_get($gurl);
function sock_get($url)
{
    $info = parse_url($url);
    $fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
    $head = "GET " . $info['path'] . "?" . " HTTP/1.0\r\n";
    $head .= "Host: " . $info['host'] . "\r\n";
    $head .= "\r\n";
    fputs($fp, $head);
    while (!feof($fp)) {
        $line = fgets($fp);
        echo $line . "<br/>";
    }
}